package applications.away3d {
	import away3d.cameras.Camera3D;
	import away3d.containers.ObjectContainer3D;
	import away3d.containers.Scene3D;
	import away3d.lights.DirectionalLight3D;
	import away3d.primitives.Sphere;

	import display3d.away3d.ViewContainer3D;

	import jazztures.geom.Point3D;
	import jazztures.utils.GeometryUtils;

	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Vector3D;

	/**
	 * @author jao
	 */
	public class TestRotation extends Sprite {
		private var camera:Camera3D;
		private var world:Scene3D;
		private var view:ViewContainer3D;
		private var light : DirectionalLight3D;
		private var container : ObjectContainer3D;
		private var sphere2Position : Vector3D;
		private var sphere2 : Sphere;
		private var sphere3Position : Vector3D;
		private var sphere3 : *;
		private var container2 : ObjectContainer3D;
		
		public function TestRotation() {
			build();
		}
		
		private function build():void{
			world = new Scene3D();
			
			light = new DirectionalLight3D();
			light.direction = new Vector3D(150,150,150);
			world.addLight(light);
		
			camera = new Camera3D();
			camera.y = 5000;
			camera.z = -5000;
			camera.rotationX = -45;
			camera.zoom = 10;
			camera.focus = 400;
			world.addChild(camera);
			
			view = new ViewContainer3D(stage.stageWidth, stage.stageHeight, camera, world);
			addChild(view);
			
			container = new ObjectContainer3D();
			world.addChild(container);
			
			var sphere:Sphere = new Sphere();
			container.addChild(sphere);
			
			container2 = new ObjectContainer3D();
			container.addChild(container2);
			
			sphere2Position = new Vector3D(500, 0, 0);
			sphere2 = new Sphere();
			sphere2.radius = 100;
			container2.addChild(sphere2);
			
			sphere3Position = new Vector3D(0, 500, 0);
			sphere3 = new Sphere();
			sphere3.radius = 100;
			container2.addChild(sphere3);
			
			addEventListener(Event.ENTER_FRAME, update);
			addEventListener(Event.ENTER_FRAME, render);
		}
		
		private function update(evt:Event):void{
			container.rotationY++;
		}
				
		private function render(evt:Event):void{
			view.render();
		}
		
	}
}